package com.cqhfan.imservice.controller;

import com.cqhfan.core.domain.dto.PageDTO;
import com.cqhfan.imservice.service.ImMessageService;
import com.cqhfan.pojo.im.dto.TogetherWatchMessageDTO;
import com.cqhfan.pojo.im.po.ImMessage;
import com.cqhfan.pojo.im.query.ChatHistoryQuery;
import com.cqhfan.pojo.im.vo.HistoryMessageVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 眭传洪
 * @create 2025-08-16 2:18
 */
@RestController
@RequestMapping("/imMessage")
@RequiredArgsConstructor
public class ImMessageController {

    private final ImMessageService imMessageService;

    @PostMapping("/sendMessage")
    public void sendMessage(@RequestBody ImMessage body) {
        imMessageService.sendMessage(body);
    }

    @GetMapping("/history")
    public PageDTO<HistoryMessageVO> history(ChatHistoryQuery query) {
        return imMessageService.history(query);
    }

    @PostMapping("/togetherWatchHandler")
    public void inviteTogetherWatch(@RequestBody TogetherWatchMessageDTO togetherWatchMessage) {
        imMessageService.togetherWatchHandler(togetherWatchMessage);
    }

}
